gusucode.com > 黑白棋 V1.0 试用网络版源代码C++源码程序 > 黑白棋 V1.0 试用网络版源代码/BWChess/03D407_庞长才_PROJECT作业/BWChess钻石版/BestDlg.cpp

    // BestDlg.cpp : implementation file
//
#include "stdafx.h"
#include "BWChess.h"
#include "Globalvar.h"
#include "BestDlg.h"
#include "HelperAPI.h"


#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CBestDlg dialog

//英雄榜对话框
CBestDlg::CBestDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CBestDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CBestDlg)
	//}}AFX_DATA_INIT
	m_DyShow=0;
}


void CBestDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CBestDlg)
	DDX_Control(pDX, IDC_RULE, m_Rule);
	DDX_Control(pDX, IDOK, m_OK);
	DDX_Control(pDX, IDC_RESTARTCOUNT, m_Reset);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CBestDlg, CDialog)
	//{{AFX_MSG_MAP(CBestDlg)
	ON_BN_CLICKED(IDC_RESTARTCOUNT, OnRestartcount)
	ON_BN_CLICKED(IDC_RULE, OnRule)
	ON_WM_PAINT()
	ON_WM_CLOSE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CBestDlg message handlers

BOOL CBestDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	HICON m_hIcon;	
	m_hIcon = AfxGetApp()->LoadIcon(IDI_HERO);
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	CenterWindow();

	m_OK.SetIcon ( IDI_OPEN );
	m_OK.SetBtnCursor(IDC_HAND);
	m_OK.AddToolTip ( _T("确定") );
	m_OK.SetActiveFgColor(RGB(0,0,255));

	m_Reset.SetIcon ( IDI_RESET );
	m_Reset.AddToolTip ( _T("重置") );
	m_Reset.SetBtnCursor(IDC_HAND);
	m_Reset.SetActiveFgColor(RGB(0,0,255));

	m_Rule.SetIcon ( IDI_RULE );
	m_Rule.AddToolTip ( _T("计分规则") );
	m_Rule.SetBtnCursor(IDC_HAND);
	m_Rule.SetActiveFgColor(RGB(0,0,255));

	Name1Edit().SetWindowText(g_strName1);//载入用户名
	Name2Edit().SetWindowText(g_strName2);
	Name3Edit().SetWindowText(g_strName3);
		
	TCHAR str[6]; 
	wsprintf(str,_T("%d"),g_nTime1);//载入棋子的个数
	Time1Edit().SetWindowText(str);
	wsprintf(str,_T("%d"),g_nTime2);
	Time2Edit().SetWindowText(str);
	wsprintf(str,_T("%d"),g_nTime3);
	Time3Edit().SetWindowText(str);

	wsprintf(str,_T("%d"),g_nMark1);//载入分数
	Mark1Edit().SetWindowText(str);
	wsprintf(str,_T("%d"),g_nMark2);
	Mark2Edit().SetWindowText(str);
	wsprintf(str,_T("%d"),g_nMark3);
	Mark3Edit().SetWindowText(str);

	UpdateData(FALSE);
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CBestDlg::OnRestartcount() //重置
{	
		g_strName1 = _T("Anonymous");
		g_nTime1 = 0;
		g_nMark1 = 0;
		Name1Edit().SetWindowText(g_strName1);
		Time1Edit().SetWindowText(_T("0"));
		Mark1Edit().SetWindowText(_T("0"));

		g_strName2 = _T("Anonymous");
		g_nTime2 = 0;
		g_nMark2 = 0;
		Name2Edit().SetWindowText(g_strName2);
		Time2Edit().SetWindowText(_T("0"));
		Mark2Edit().SetWindowText(_T("0"));	

		g_strName3 = _T("Anonymous");
		g_nTime3 = 0;
		g_nMark3 = 0;
		Name3Edit().SetWindowText(g_strName3);
		Time3Edit().SetWindowText(_T("0"));
		Mark3Edit().SetWindowText(_T("0"));

		UpdateData(FALSE);
	
}

void CBestDlg::OnRule() //关于规则
{
	MsgBox(IDS_RULE_CONTENT,IDS_RULE_TITLE); 
}

void CBestDlg::OnPaint() 
{
	CPaintDC dc(this);
	if(m_DyShow==0)
	{
		m_DyShow++;
		DynamicShow(this,1);
	}
}


void CBestDlg::OnOK() 
{
	DynamicShow(this,0);		
	
	CDialog::OnOK();
}

void CBestDlg::OnClose() 
{
	DynamicShow(this,0);		
	CDialog::OnClose();
}